<?php
	require_once "dBConnect.php";
	require_once "commonfuncs.php";
	require_once 'Zend/Loader.php';
	Zend_Loader::loadClass('Zend_Gdata');
	Zend_Loader::loadClass('Zend_Gdata_AuthSub');
	session_start();
	
	$db = new dBConnect();
	$username = $_SESSION['username'];
	
	$usrDetails = $db->getData("email, firstname, lastname", "users", "username='$username'");
	$_SESSION['email'] = $usrDetails[0]['email'];
	$email = $usrDetails[0]['email'];
	$firstname = $usrDetails[0]['firstname'];
	$lastname = $usrDetails[0]['lastname'];
	$teams = $db->getData("teamname, teamid", "teams, team_members", "email='$email' AND id=teamid");	


?>

<form method="post" action="modifyDetails.php" onsubmit="return" >
<table>
<thead><tr><th>View/Modify Account Details<BR><BR></th></tr></thead>
<tbody>
	<tr>
		<td><b>Username: </b></td> 
		<td><?php echo $username ?></td>
	</tr>
	<tr>
		<td><b>E-Mail:</b></td> 
		<td><?php echo $email ?></td>
	</tr>
	<tr>
		<td><b>First Name: </b></td> 
		<td><input type="text" name="firstname" value="<?php echo $firstname ?>"></td>
	</tr>
	<tr>
		<td><b>Last Name: </b></td> 
		<td><input type="text" name="lastname" value="<?php echo $lastname ?>"></td>
	</tr>
	<tr>
	<td valign=top><b>Team Memberships:</b>
	<BR>Uncheck to leave team.</td>
	<td>
	<?php 
		foreach ($teams as $team) {
			echo "<INPUT TYPE='checkbox' name='teams[]' value=".$team['teamid']." checked='yes'>"; 
			echo $team['teamname'].'<BR>';
		}
	?>
	</td>
	</tr>
	<tr><td colspan=2><BR><BR><input type="submit" value="Modify Details" /> <input type="button" value="Cancel" onclick="cancel(resetAddEventForm)"/></td></tr>
</tbody>
</table>
</form>